package com.ymatou.iapi.livebuyer.testcase;

import org.junit.After;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.livebuyer.parameter.UpdateLiveDescBean;
import com.ymatou.iapi.livebuyer.service.UpdateLiveDescCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.LiveRoom;
import com.ymttest.database.mongo.jproduct.LivesWapper;
import com.ymttest.database.sqlwapper.LiveRoomWapper;
import com.ymttest.utils.TestDataManager;
/**
*更新直播间信息
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_UpdateLiveDesc{
	private static UpdateLiveDescBean updatelivedescBean;
	private static UpdateLiveDescCall updatelivedescCall;
	private static LiveRoomWapper livesWapper ;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("更新直播间信息");
	}

	@Before
	public void caseUp() {
		updatelivedescBean=new UpdateLiveDescBean();
		updatelivedescCall=new UpdateLiveDescCall();
		livesWapper = new LiveRoomWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(updatelivedescCall.getOpurl());
		livesWapper=null;
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateLiveDesc_001() {
		Logger.start(true,"更新直播间信息成功");
		try {
			int liveid=new LiveRoomWapper().selectLastLiveRoom().getId();
			updatelivedescBean.setLiveId(liveid);
			updatelivedescBean.setLiveDesc("autotest更新Desc"+TestDataManager.getRandomIntNum(4));
			updatelivedescCall.setData(updatelivedescBean);
			updatelivedescCall.callService();			
			Logger.verifyEquals("200", updatelivedescCall.getString("code"), "判断code");
			LiveRoom liveroom = livesWapper.selectLiveRoomById(liveid);
			Logger.verifyEquals(updatelivedescBean.getLiveDesc(), liveroom.getLiveDesc(), "验证LiveDesc");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_UpdateLiveDesc_002() {
		Logger.start(true,"不输入liveId失败");
		try {
//			updatelivedescBean.setLiveId(35);
			updatelivedescBean.setLiveDesc("autotest更新Desc"+TestDataManager.getRandomIntNum(4));
			updatelivedescCall.setData(updatelivedescBean);
			updatelivedescCall.callService();			
			Logger.verifyEquals("100", updatelivedescCall.getString("code"), "判断code");
			Logger.verifyIsContains("错误的请求参数", updatelivedescCall.getString("message"), "判断message");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_UpdateLiveDesc_003() {
		Logger.start(true,"不输入liveDesc更新liveDesc为空");
		try {
			int liveid=new LiveRoomWapper().selectLastLiveRoom().getId();
			updatelivedescBean.setLiveId(liveid);
			updatelivedescCall.setData(updatelivedescBean);
			updatelivedescCall.callService();			
			Logger.verifyEquals("200", updatelivedescCall.getString("code"), "判断code");
			LiveRoom liveroom = livesWapper.selectLiveRoomById(liveid);
			Logger.verifyEquals("", liveroom.getLiveDesc(), "验证LiveDesc");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}